package com.nlscan.ncomgateway.core.sdk.udp

import com.nlscan.qdkit.common.core.util.StringUtils
import com.nlscan.ble.util.NLogUtil
import com.nlscan.ble.util.NStringUtil
import com.nlscan.ncomgateway.core.newland.helper.NlsIpCommandHelper
import net.x52im.mobileimsdk.android.event.CustomMessageEvent
import java.nio.charset.Charset

/**
 * <pre>
 *  author: lin.qing
 *  time  : 2024/12/10
 *  desc  :
 * </pre>
 */
class UdpCustomEventImpl : CustomMessageEvent {


    override fun onReceiveMessage(data: ByteArray?, len: Int) {
        data?.let {
            val msg = String(it, 0, len, Charset.forName("utf-8"))
            NLogUtil.i("UdpCustomEventImpl onReceiveMessage msg: $msg")
            val command = NlsIpCommandHelper.parse(msg)
            NlsIpCommandHelper.sendIpCommand(command)
        }
    }
}